import { Injectable } from '@angular/core';

import {HttpService} from '../shared/http/http.service';
import {ConfigProvider} from '../providers/config.provider';

import {MenuModel} from '../models/MenuModel';

/*
* 帐号服务
*/
@Injectable()
export class SysService {

    constructor(
        private httpService: HttpService
    ) {

    }

    public getMenus(callback) {
        const loginUrl = ConfigProvider.passportBaseURL + 'api/sys/getMenus';
        this.httpService.get(loginUrl, null,
        function (successful, data, res) {
          if (successful && callback) {
              const menuData = (<Array<MenuModel>>data.result);
              console.log(menuData);
              callback(true, menuData);
          }
        }, function (successful, msg, err) {
            if (callback) {
                console.log(msg);
                callback(false, err);
            }
        });
    }

}
